<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="container1">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div>111</div>
        <div>222</div>
        <div>333</div>
    </div>

    <div class="container2">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div>111</div>
        <div>222</div>
        <div>333</div>
    </div>

    <div class="container3">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div>111</div>
        <div>222</div>
        <div>333</div>
    </div>
    <script>

        var btns = document.querySelectorAll(".container1 button");
        var divs = document.querySelectorAll(".container1 div");
        Tab(btns,divs);

        var btns2 = document.querySelectorAll(".container2 button");
        var divs2 = document.querySelectorAll(".container2 div");
        Tab(btns2,divs2);

        var btns3 = document.querySelectorAll(".container3 button");
        var divs3 = document.querySelectorAll(".container3 div");
        Tab(btns3,divs3);


        function Tab(btns,divs) {
            btns.forEach((btn, key) => {
                btn.onclick = function () {
                    divs.forEach((div, k) => {
                        if (k == key) {
                            divs[k].style.display = "block";
                        } else {
                            divs[k].style.display = "none";
                        }
                    })
                }
            })
        }



    </script>
</body>

</html>